package com.dsr.controller;

import com.dsr.consts.Result;
import com.dsr.entity.Collect;
import com.dsr.service.CollectService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * (Collect)表控制层
 *
 * @author dsr
 * @since 2020-10-07
 */
@Api(tags = "(Collect)表控制层")
@RestController
@RequestMapping("/collect")
public class CollectController {

    @Autowired
    private CollectService collectService;

    @ApiOperation("判断是否收藏")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "flowerId", value = "flowerId", required = true)
    })
    @GetMapping("/get/{flowerId}")
    public Result getEntity(@PathVariable String flowerId) {
        return collectService.getEntity(flowerId);
    }

    @ApiOperation("保存操作")
    @ApiParam(name = "collect", value = "实体", required = true)
    @PostMapping("/save")
    public Result save(@RequestBody  Collect collect) {
        return collectService.save(collect);
    }



    @ApiOperation("根据id删除")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path",name = "flowerId", value = "flowerId", required = true)
    })
    @DeleteMapping("/delete/{flowerId}")
    public Result delete(@PathVariable String flowerId) {
        return collectService.delete(flowerId);
    }

    @ApiOperation("查询收藏")
    @GetMapping("/list")
    public Result list() {
        return collectService.list();
    }
}